/*
 * 项目组:
 *            = = =      =       =      =       =       =
 *          =            =       =       =     = =     =
 *         =             = = = = =        =   =   =   =
 *          =            =       =         = =     = =
 *            = = =      =       =          =       =
 */
$(function () {

    var bookTypes;
    $.ajax({
        url: "/book/book/findAllTypes",
        type: "post",
        dataType: "json",
        success: function (result) {
            console.log(result)
            if (result.status !== 2001) {
                alert(result.msg);
            } else {
                bookTypes = result.data;
            }
        }
    })
    // 书品分类 二级菜单数据展示
    // 该 事件 只提供 思路 和 模拟数据操作，实际项目开发需要自行修改
    $("#bookTypesMenu > li:not(:last-child)").hover(function () {
        $("#typesDetail").html("");
        var key = $(this).attr("data-type-id");
        var types = bookTypes[key];

        types.forEach(function (t) {
            var $typeList = $("<ul></ul>");

            t.content.forEach(function (item) {
                $typeList.append(`<li><a href="./bookList.html">${item}</a></li>`)
            });
            $('<div class="topbar-detail-types"></div>').append(`<p>${t.name}</p>`)
                .append($typeList)
                .appendTo($("#typesDetail"));

        });
        $("#typesDetail").css("display", "block");
    }, function () {
        $("#typesDetail").css("display", "none");
    });

// ----------------------------------------------------------------
    // 二级菜单显示效果操作，请勿修改，除非你知道在干嘛 ->
    $("#typesDetail").hover(function () {
        $(this).css("display", "block");
    }, function () {
        $(this).css("display", "none");
    });
    // <- 二级菜单显示效果操作，请勿修改，除非你知道在干嘛
// ----------------------------------------------------------------
});